﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace BLL
{
    public class WebPageSecurity : System.Web.UI.UserControl
    {
        protected override void OnInit(EventArgs e)
        {
            if (HttpContext.Current.Request.QueryString["mod"] != null)
            {
                if (!new CmsBLL().HasPermissionView(HttpContext.Current.Request.QueryString["mod"].ToString()))
                    Response.Redirect("~/administrator/default.aspx?mod=denyaccess");
            }
            if (HttpContext.Current.Request.QueryString["view"] != null)
            {
                if (!new CmsBLL().HasPermissionViewItem(HttpContext.Current.Request.QueryString["view"].ToString()))
                    Response.Redirect("~/administrator/viewitem.aspx?view=denyaccess");
            }
            if (HttpContext.Current.Request.QueryString["add"] != null)
            {
                if (!new CmsBLL().HasPermissionAdd(HttpContext.Current.Request.QueryString["add"].ToString()))
                    Response.Redirect("~/administrator/addnewitem.aspx?add=denyaccess");
            }
            if (HttpContext.Current.Request.QueryString["edit"] != null)
            {
                if (!new CmsBLL().HasPermissionEditItem(HttpContext.Current.Request.QueryString["edit"].ToString()))
                    Response.Redirect("~/administrator/edititem.aspx?edit=denyaccess");
            }
            base.OnInit(e);
        }
    }
}
